<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图书列表</title>
</head>
<body>
    <h1>图书列表</h1>
    <table border="1" width="700" cellspacing="0">
        <tr>
            <th>ID</th>
            <th>书名</th>
            <th>出版社</th>
            <th>价格</th>
            <th>零售价</th>
            <th>添加时间</th>
            <th>操作</th>
        </tr>
        {{ range $key, $value := .books }}
        <tr>
            <td>{{ $value.ID }}</td>
            <td>{{ $value.Title }}</td>
            <td>{{ $value.Pub }}</td>
            <td>{{ $value.Price }}</td>
            <td>{{ $value.Market_price }}</td>
            <!-- 时间是一个time对象格式，需要格式化为字符串 -->
            <td>{{ $value.CreatedAt.Format "2006-01-02 15:04:05" }}</td>
            <td>
                <a href="/update_book?id={{ $value.ID }}">修改</a>
                <a href="/delete_book?id={{ $value.ID }}">删除</a>
            </td>
        </tr>
        {{ end }}
    </table>
</body>
</html>